package bpm.dao.impl.deptagenda;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;

import org.springframework.jdbc.core.RowMapper;

import bpm.domain.deptagenda.DeptAgenda;
/**
 * 
 * @author wanglong635@126.com
 *
 */
public class DeptAgendaMapper implements RowMapper {

	public Object mapRow(ResultSet rs, int i) throws SQLException {
		DeptAgenda agenda = new DeptAgenda();
		agenda.setAgendaId(rs.getString("AGENDAID"));
		agenda.setRegisterId(rs.getString("REGISTERID"));
		agenda.setRegisterName(rs.getString("REGISTERNAME"));
		agenda.setRegisterDeptCode(rs.getString("REGISTERDEPTCODE"));
		agenda.setRegisterDeptName(rs.getString("REGISTERDEPTNAME"));
		
		Timestamp registTime = rs.getTimestamp("REGISTTIME");
		if(registTime!=null)
			agenda.setRegistTime(String.format("%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS", registTime));
		
		Timestamp updateTime = rs.getTimestamp("UPDATETIME");
		if(updateTime!=null)
			agenda.setUpdateTime(String.format("%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS", updateTime));
		
		Timestamp startTime = rs.getTimestamp("STARTTIME");
		if(startTime!=null)
			agenda.setStartTime(String.format("%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS", startTime));
		
		Timestamp endTime = rs.getTimestamp("ENDTIME");
		if(endTime!=null)
			agenda.setEndTime(String.format("%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS", endTime));
		
		agenda.setAgendaContent(rs.getString("AGENDACONTENT"));
		agenda.setState(rs.getString("STATE"));
		agenda.setShare(rs.getString("SHARE"));
		agenda.setAddress(rs.getString("ADDRESS"));
		agenda.setRemark(rs.getString("REMARK"));
		
		return agenda;
	}

}
